package top.italks.manufactureproject.ui.rencai.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import top.italks.manufactureproject.R;
import top.italks.manufactureproject.ui.rencai.bean.PeopleGetAll;
import top.italks.manufactureproject.ui.rencai.bean.PeopleGetAll.DataBean;

public class TalentAdapter extends BaseAdapter {

    private List<PeopleGetAll.DataBean> peopleList;
    private Context mContext;

    public TalentAdapter(Context context) {
        mContext = context;
        peopleList = new ArrayList<>();
    }

    public List<DataBean> getPeopleList() {
        return peopleList;
    }

    public void setPeopleList(
        List<DataBean> peopleList) {
        this.peopleList = peopleList;
    }

    @Override
    public int getCount() {
        return peopleList.size();
    }

    @Override
    public PeopleGetAll.DataBean getItem(int position) {
        return peopleList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext)
                .inflate(R.layout.talent_list_item, parent, false);
        }
        TextView name = convertView.findViewById(R.id.name);
        TextView status = convertView.findViewById(R.id.status);
        TextView gold = convertView.findViewById(R.id.gold);

        name.setText(peopleList.get(position).getPeopleName());
        switch (peopleList.get(position).getStatus()) {
            case 0:
                status.setText("工程师");
                break;
            case 1:
                status.setText("工人");
                break;
            case 2:
                status.setText("技术人员");
                break;
            case 3:
                status.setText("检测人员");
                break;
        }
        gold.setText(String.valueOf(peopleList.get(position).getGold()));

        return convertView;
    }
}
